﻿
<InfoCard Href="@(AllowNav?("/entries/index/" + Model.Id):null)" BriefIntroduction="@Model.BriefIntroduction" Image="@Model.MainImage" InfoItems="GetInfoItems()" Name="@Model.Name" Type="@(ShowType?Model.Type.GetDisplayName():"")" Outline="Outline"
          Thumbnail="Model.Type == EntryType.Role || Model.Type == EntryType.Staff" BigCardStyle="BigCardStyle" AddInfors="Model.AddInfors" ShowAddInfors="ShowAddInfors" IsEdit="IsEdit">
    <TitleContent>
        <CnGalWebSite.Components.Audios.AudioButton Url="@Model.Audio.FirstOrDefault()?.Url" Class="ms-2" />
    </TitleContent>
</InfoCard>


@code {
    [Parameter]
    public EntryInforTipViewModel Model { get; set; }
    [Parameter]
    public bool IsEdit { get; set; }
    [Parameter]
    public bool ShowType { get; set; } = true;
    [Parameter]
    public bool Outline { get; set; }
    [Parameter]
    public bool ShowAddInfors { get; set; } = true;
    [Parameter]
    public bool ShowDetailNumber { get; set; } = true;
    [Parameter]
    public bool AllowNav { get; set; } = true;
    /// <summary>
    /// 强制大卡片样式
    /// </summary>
    [Parameter]
    public bool BigCardStyle { get; set; }
    [Parameter]
    public bool ForcedShowPublishTime { get; set; }

    public List<(IconType, string)> GetInfoItems()
    {
        if (ShowDetailNumber==false||Model.Type!= EntryType.Game)
        {
            return null;
        }
        var items = new List<(IconType, string)>
        {
            (IconType.Comment,Model.CommentCount.ToString()+"条评论"),
            (IconType.Read,Model.ReaderCount.ToString()+"次阅读"),
        };

        var time = "未知";
        if (Model.PublishTime != null)
        {
            if (Model.PublishTime.Value > DateTime.Now.ToCstTime() && ForcedShowPublishTime == false)
            {
                time = "未发售";
            }
            else
            {
                time = (Model.Type == EntryType.Game ? Model.PublishTime.Value : Model.LastEditTime).ToString("yyyy-MM-dd");
            }
        }
        items.Insert(0, (IconType.DeterminedTime, time));

        return items;
    }
}
